﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;

namespace Clotho.MdStore {
	public class MdFactory {
		Dictionary<string, Type> ItemTypeTable;
		public bool register(Type t) {
			if (typeof(IMdItem).IsAssignableFrom(t) ){
				ItemTypeTable.Add(t.Name, t);
				return true;
			}
			else {
				return false;
			}
		}
		public IMdItem bulid(string type_str) {
			if (ItemTypeTable[type_str] is null) {
				return null;
			}
			else {
				return System.Activator.CreateInstance(ItemTypeTable[type_str]) as IMdItem;
			}
		}
	}
}
